Combining partial evaluation and staged interpretation in the implementation of domain-specific languages
نویسندگان
چکیده
We propose a combination of partial evaluation and staged interpretation with MetaOCaml for rapid prototyping of domain-specific languages. Interpretation is an easy way to implement such languages. MetaOCaml can eliminate the overhead of interpretation at run time, if the interpreter is written in a staged form, i.e., takes the source program separate from the input data in a first stage. Partial evaluation of the source program with values known at compile time can further improve the target code performance. Additional aggressive optimizations are possible due to the absence of general recursion. Algebraic simplifications can even achieve binding-time improvements during the online partial evaluation. Our approach both saves the application programmer completely from binding-time considerations and exploits staged interpretation with MetaOCaml for target code generation. The example domain presented in this paper is image processing, in which the domain-specific language permits the specification of convolution matrices, summations, case distinctions and non-local pixel accesses. All expressions known at compile time are simplified and all remaining expressions are turned into MetaOCaml code parts, which are combined to form the compiled application program. The example specifications deal with filtering by convolution and iterations in a series of images for wave effects and temperature distribution. The experimental results show significant speedups if online partial evaluation with algebraic simplifications is used for elimination of interpretation overhead and optimization of code expressions.
منابع مشابه
Stage-preserving Embeddings of Languages
Embeddings of languages into one another are useful in studying their relative power and, sometimes, finding languages that are universal in some sense. Examples include Turing-reducibility for studying computability, poly-time reductions for subrecursive languages [14], and structure-preserving embeddings for expressiveness [4, 5, 13, 12]. To further a search for languages suitable for “domain...
متن کاملOn the Logical Foundations of Staged Computation (Invited talk)
Dividing a omputation into stages and optimizing later phases using information from earlier phases is a familiar te hniquein algorithm design. In the realm of programming languages, staged omputation has found two important realizations:partial evaluation and run-time ode generation. A priori, these are fundamentally operational on epts, on erned with howa program exe utes, but...
متن کاملLanguages with Concatenation ∗
Parsing for Two-staged Languages with Concatenation ∗ Soonho Kong Wontae Choi Kwangkeun Yi Seoul National University {soon,wtchoi,kwang}@ropas.snu.ac.kr Abstract This article, based on Doh, Kim, and Schmidt’s “abstract parsing” technique, presents an abstract interpretation for statically checking the syntax of generated code in two-staged programs. Abstract parsing is a static analysis techniq...
متن کاملPartial Evaluation + Reflection = Domain Specific Aspect Languages
Domain-specific languages (DSLs) are typically implemented by code generation, in which domain-specific constructs are translated to a general-purpose “host” language. Aspect-oriented languages go one step further. An aspect weaver doesn’t just generate code, it transforms code in the host language. In both cases, one of the major challenges in building and using the DSL is achieving good integ...
متن کاملStaging & Embedded Domain Specific Languages
Multi-Stage Programming (MSP) is a programming language feature that allows to define high-level abstractions describing generic, hihly-parametrized code, while removing these abstractions at runtime during a succession of code generation phases (called stages): the last stage corresponds to the actual program execution. MSP removes these abstractions in a process akin to partial evaluation and...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Sci. Comput. Program.
دوره 62 شماره
صفحات -
تاریخ انتشار 2006